<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html style="overflow: hidden;height:100%;">
	<head>
		<title>${lotter.name }</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<style type="text/css">
			.qiu{margin-right:3px;color:white;width:22px;height:22px;line-height:22px;font-size:12px;display:inline-block;background: #E63131;}
			.btn2{background: none;border: 0;color: #009ac3;font-size: 15px;padding:3px 0px; border-radius:5px;}
			/**.btn2{background: none;border: 0;color: #fff;font-size: 15px;padding:3px 5px;border-radius:5px;}*/
			.btn3{border:0px;border-radius:50px;padding:2px;width:26px;height:26px;line-height:20px;color: white;}
			.qiu0{background: #D8D21C!important;}
			.qiu1{background: #D8D21C!important;}
			.qiu2{background: #3273F9!important;}
			.qiu3{background: #515567!important;}
			.qiu4{background: #E6962D!important;}
			.qiu5{background: #0EC2C4!important;}
			.qiu6{background: #2D35D0!important;}
			.qiu7{background: #AEAFC5!important;}
			.qiu8{background: #E63131!important;}
			.qiu9{background: #7C1F1F!important;}
			.qiu10{background: #2DCC21!important;}
			.hb{background: #F02828;}
			.lbo{background: #336DCC;}
			.lvbo{background: #09B832;}
			.table1{margin-top: 5px;}
			.table1 tr td{height: 30px;padding:0 5px;font-size: 14px;}
			.ctr{color: ;font-weight: bold;}
			.xiazhu .title{background:#EFEFEF;padding: 8px;border-bottom: 1px solid silver;}
			.xiazhu .col-xs-6,.xiazhu .myfl{border: 1px solid #ECECEC ;padding: 5px;padding: 13px 0px;}
			.xiazhu .col-xs-6 button{margin-right: 20px;}
			.xiazhu .row{margin: 0px;}
			.xiazhu input{display:none;border:1px solid red;}
			.xiazhu span{color: gray;display: inline-block;min-width: 40px;font-size: 12px;}
			.xiazhu .act{background: url("//img/actbg.png");background-size: 20px 20px;background-repeat: no-repeat;}
			/* .xiazhu .act *{color: white;} */
			
			.zdsd *{font-size: 14px;}
			.hemei input{text-align: center;}
			
			*{font-size: 14px;}
			.wf a{background: #EFEFEF;color:black; width: 98%;text-align: center;padding:5px;display: block; display: -moz-box;border: 1px solid white;font-size: 12px;cursor: pointer;}
			.wf .acti{background: #02AECB;color: white;}
			.wfdiv:after {
                content: ".";
                display: block;
                height: 0;
                visibility: hidden;
                clear: both;
            }
            .clearfix:after {
                content: ".";
                display: block;
                height: 0;
                visibility: hidden;
                clear: both;
            }
            .modal-dialog {
            	margin:10px 0!important;
            }
			.nav a{color:white;}
			#myModal .modal-dialog, #betSuccessModal .modal-dialog {margin: 0 auto!important;padding:10px;}
			.item .important{color:red;font-weight :bold;}
			.item .nickname{color:#099afe}
			.item,.item *{font-size:12px;}
			.item{padding-left:30px;}
			.nav>li>span {
				color:white;
				position: relative;
    display: block;
    padding: 10px 15px;
			}
			.wf {width:100px;overflow:auto;max-height:100%;-webkit-overflow-scrolling: touch;}
.div-c-lotteryRecordItem {
				
			}
.green{border-radius:10px; border:1px solid silver ;box-shadow: 2px 3px 1px silver;padding:10px;padding-left:10px; ;line-height:30px;margin-bottom: 20px;text-align: left;}
			.green{border-top:5px solid green;}
			
			.span-item-circle {
				display: inline-flex;
			    background: red;
			    margin: 1px;
			    border-radius: 50%;
			    color: white;
				font-size: 0.33rem;
			    width: 0.46rem;
			    height: 0.46rem;
			    justify-content:center;
			    align-items:center;
			    max-width:26px;
			    max-height:26px;
			}
			.clearfix:after {
				content:"";
				display:block;
				clear:both;
			}		
			.modal-footer {
				padding:6px;
				text-align: center;
			}	
			.modal-footer > button {
				width:80%;
			}
			.ul-c-betSuccessItem {
		  		border-radius: 10px;
			    border: 1px solid silver;
			    box-shadow: 2px 3px 1px silver;
			    padding: 10px;
			    padding-left: 30px;
			    line-height: 30px;
			    margin-bottom: 20px;
			    text-align: left;
			    overflow: auto;				
			}
			#betSuccessModal .modal-body {
				max-height:80vh;
			}
			#checkboxhm, #checkboxgd {
				width:20px;
				height:20px;
			}
			.zdsd.set {
				max-width:360px;
				left:50%!important;
				transform:translateX(-50%);
				margin:0!important;
			}
			.col-sm-4, .col-xs-12 {
				padding-left:0;
				padding-right:0;
			}
			.clearfix:after {
				content:"";
				display:block;
				clear:both;
			}
			.nav>li>span:hover {
				background-color:#eee;
			}
			.xiazhu > div > div, #id-ul-xiaLaMenu > li > a, #id-ul-xiaLaMenu > li > span {
				cursor: pointer;
			}
			.xiazhu > div > .title {
				cursor: default;
			}
			.span-c-gendanWrapper, .span-c-hemaiWrapper {
				display:none;
			}
			.span-c-gendanWrapper.active, .span-c-hemaiWrapper.active {
				display:inline-block;
			}
		</style>
	</head>
	<body style="height: 100%;">
		<div class="" style="display:none; padding:0;">
			<span id="id" class="hidden">${lotter.id }</span>
			<span id="cplay1" class="hidden">${keyChinese }</span>
			<span id="cname1" class="hidden">${lotter.name }</span>
			<span id="orderid" class="hidden"></span>
			<span id="cname" class="hidden">${lotter.cname }</span>
			<span class="timespace hidden">${lotter.timespace }</span>
			<span id="lasttime" class="lasttime hidden">${lotter.lottertime }</span>
			<span id="cplay" class="hidden">${key}</span>
			<div class="" style="background: url("/img/actbg.png");"></div>
		</div>	
		<div style="display:flex;flex-direction:column;height:100%;" class="clearfix"> 
			<div id="id-div-headerNav" class="col-xs-12 col-sm-4 col-sm-offset-4" style="display:flex;justify-content:space-between;background-color:rgb(236,74,19);align-items:center;padding:0 10px;height:50px;position:fixed;z-index:4;">
			
				<a href="/gc.do" class="glyphicon glyphicon-chevron-left" style="color: white;margin-top:-4px;"></a>
				<div style="position:absolute;transform:translateX(-50%) translateY(-50%);left:50%;top:50%;">
					<div class='font12	' style="color:yellow;">当期下注总额：<span id="span-i-xiazhuzonge"></span></div>
					<div style="color: white;font-weight: bold;font-size: 16px;text-align: center;">${lotter.name }</div>
				</div>
				
				<div style="display:flex;align-items:center;"class="user">
					<div style="color: white;display:flex;flex-direction:column;align-items:flex-end;margin-right:10px;line-height:14px;">
						<span style="font-size: 12px;">余额</span>
						<span style="font-size: 12px;" id="balance">￥${user.balance }</span>
					</div>	
					<i class="glyphicon glyphicon-menu-hamburger" style="font-size:20px;color:white;cursor: pointer;"></i>
				</div>	
	
				<ul id="id-ul-xiaLaMenu" class="nav hidden" style="position: absolute;left:auto;right:0px;top:100%;width:100px;text-align: center;z-index:100;background: RGBA(250,85,50,0.8) ;border-radius:0; ">
					<li><a href="/order/myOrders.do?key=all">下注记录</a></li>
					<li><a id="a-i-lotterRecord">开奖记录</a></li>
					<!-- <li><a href="javascrpit:;" id="a-i-zoushitu">走势图</a> -->
					<li><span id="a-i-zoushitu">走势图</span>
					<li><a onclick="help('${lotter.cname}','${lotter.name }')">购彩助手</a></li>
					<li><a href="/wd.do">我的地盘</a></li>
					<li><a href="/exit.do">退出登录</a></li>
				</ul>	
			</div>
			<div style="background-color:white;line-height:25px;padding:0 10px;top:50px;position: fixed;z-index:3;"class="class-div-qiuGroups col-xs-12 col-sm-4 col-sm-offset-4">
				<p style="margin-bottom:0px;"><span style="font-size: 14px;" class="period">${lotter.period }</span><span class=""> 期：</span><span class="lotternumber">${lotter.lotternumber }</span></p>
				<p style="padding-top:4px;margin-bottom:0px;"><span style="font-size: 14px;" class="xiaqi">${lotter.period+1 }</span> 期： <span id="djs" style="font-size: 14px;font-weight: bold;"></span></p>
				<div title="1463" class="kd-marquee kd-container" style="max-width:100%;overflow:hidden;">
					<div id="test1" class="inner" >
						<nobr>
						</nobr>
					</div>
				</div>				
			</div>
			<div style="display:flex;margin-top:130px;margin-bottom:66px;" class="class-div-contentDiv col-xs-12 col-sm-4 col-sm-offset-4">	
					${str }
				<div class="clearfix xiazhu" style="overflow:auto;-webkit-overflow-scrolling: touch;position:relative;z-index:2;text-align:center;">
					<!-- 下注区 -->
						${xiazhuqu }
					<!-- 下注区 -->
				</div>	
			</div>
			<div style="position: fixed;bottom:0;z-index:3;" id="div-i-footer-hemai" class="col-xs-12 col-sm-4 col-sm-offset-4">
				<div style="display:flex;justify-content:space-between;align-items:center;border-top:2px solid silver;padding:5px 10px;height: 66px;background: white;" id="foot" class="">
					<div class="" style="padding: 0;text-align: left;">
						<div class="font10">已选 <span id="zhushu">0</span> 注，单注金额</div>
						<div><input id="dzje" style="width:108px;border-radius: 5px;border: 1px solid silver ;" value="2" /></div>
					</div>
					<div class="" style="">
						<c:if test="${user.state=='1' }">
							<span class="span-c-hemaiWrapper"><input type="checkbox" id="checkboxhm" /><span class="font14"> 合买</span></span>
							<br>
							<span class="span-c-gendanWrapper"><input type="checkbox" id="checkboxgd" /><span class="font14"> 跟单</span></span>
						</c:if>
					</div>
					<div class="" style="">
						<a onclick="clear1()" class="btn btn-sm" style="background: #eb6066;color:white;border:1px solid #eb6066;margin-right: 10px;">清空</a>
						<a id="queding" onclick="comit()" class="btn btn-sm queren" style="border:1px solid black;">确定</a>
					</div>
				</div>		
			</div>
		</div>
	<div class="zdsd hidden" style='position: fixed;top:0;left:0;width: 100%;height: 100%;z-index: 60;background:rgba(0,0,0,0.5) ;'>
	</div>
	<div class="zdsd hidden set" style='position: fixed;left:0;z-index: 100;color: gray;padding: 15px;text-align: left;background: white;height: 200px;width: 80%;margin:10% ;bottom: 50px;border-radius:20px;border: 1px solid gray; '>
		<ul style="width: 100%;">
			<li class="hemei" style="text-align: center;padding:0 10px 10px;">
				<strong style="font-size: 20px;color: black;">合 买 设 置</strong>
			</li>
			<li class="hemei" style="line-height: 25px;">
				<span>我要分为：<input class="fs" style="width: 40px;border:1px white solid;border-bottom:1px solid gray;" value="0" /> 份　<span style="color: red;font-size: 10px;">每份￥<span class="meifen" style="color: red;font-size: 10px;">0.00</span>元</span></span><br>
				<!-- <span>我要提成：税后盈利的 <select><option class="tc">0%</option><option>1%</option><option>2%</option><option>3%</option><option>4%</option><option>5%</option><option>6%</option><option>7%</option><option>8%</option></select></span><br> -->
				<span>我要认购：<input class="rg" style="width: 40px;border:1px white solid;border-bottom:1px solid gray;" value="0" /> 份　<span style="color: red;font-size: 10px;">￥<span class="rengou" style="color: red;font-size: 10px;">0</span>元</span></span><br>
				<span>我要保底：<input class="bd" style="width: 40px;border:1px white solid;border-bottom:1px solid gray;" value="0"/> 份　<span style="color: red;font-size: 10px;">￥<span class="baodi" style="color: red;font-size: 10px;">0</span>元</span></span><br><br>
			</li>
			
			<li style="text-align: center;line-height: 40px;border-top: 1px solid gray;">
				<a class="col-xs-6" style="border-right: 1px solid gray;" onclick="cancel()">取 消</a>
				<a class="col-xs-6" style="color: blue;" onclick="submit()" >确 定</a>
			</li>
		</ul>
	</div>		

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel" style="text-align: center;letter-spacing: 3px;">★${lotter.name }★</h4>
            </div>
            <div class="modal-body" style="height:65vh;overflow:auto;">
 				
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关　闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->	
<!-- 模态框（Modal） -->
<div class="modal fade" id="betSuccessModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 style="text-align: center;font-weight:bold;" class="modal-title" id="myModalLabel">下注成功！</h4>
            </div>
            <div class="modal-body" style="overflow: auto;">
            	<ul class="ul-c-betSuccessItem">
<!--             		<li>★玩法:</li>
            		<li>★预估收益值:</li>
            		<li>★下注号码:</li> -->
            	</ul>
            </div>
            <div class="modal-footer">
                <button style="" type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
	
<div class="modal-div-fakeModal" id="div-i-noticeGenDan">
	<div class="div-c-modalContent">
		<h3 class="fakemodal-title"></h3>
		<div class="fakemodal-content"></div>
		<div class="fakemodal-btnsGroup"><button class="btn btn-default btn-class-closeFakeModal">关闭</button></div>
	</div>
</div>		
	
	</body>
	<script type="text/javascript" src="/js/zhengzeTools.js"></script>
	<script type="text/javascript">
 	var SPECIAL_CAIZHONG = ["bjpk10", "2fpk10"]
 	var MONEY_FROM_SERVER = ""
 	var COUNT_FROM_SERVER = 0
	var COLOR_OBJECT = {
			"1": "qiu1",
			"2": "qiu2",
			"3": "qiu3",
			"4": "qiu4",
			"5": "qiu5",
			"6": "qiu6",
			"7": "qiu7",
			"8": "qiu8",
			"9": "qiu9",
			"10":  "qiu10"
	} 
	function jianrong() {
		/* 动态设置 html font-size, 使用 rem 适配 */
		var htmlSelector = document.documentElement
		var width = htmlSelector.clientWidth
		if (width > 400) {
			width = 400
		}
		var fSize = width / 7.5
		htmlSelector.style.fontSize = String(fSize) + "px"
		htmlSelector.dataset.fontrem = fSize.toFixed(2)
	}
	jianrong();	
	function cancel(){$(".zdsd").addClass("hidden");$("#checkboxhm").removeAttr("checked");}
	
	function checkHeMaiAndGenDanStatus() {
		// span-c-hemaiWrapper
		// span-c-gendanWrapper
		// gendan
		// hemai
			var newRequest = {
				url: "/cplayFlag.do",
				type: "post",
				data: {},
				success: function(data) {
					var newData = JSON.parse(data)
					if (newData.data.gendan === 1) {
						$(".span-c-gendanWrapper").addClass("active")
					}
					if (newData.data.hemai === 1) {
						$(".span-c-hemaiWrapper").addClass("active")
					}					
				},
				error: function(status) {
				}
			}
			ajax(newRequest)		
	}
	checkHeMaiAndGenDanStatus()
	function setSlideData() {
	 	var urlPath = "/order/xzdata.do"
			var newRequest = {
				url: urlPath,
				type: "post",
				data: {cname:$("#cname").text()},
				success: function(data) {
					var newData = JSON.parse(data)
					for (var i = 0; i < newData.data.length; i++) {
						var item = newData.data[i]
						// huiyuanzh 一位变星号 
						// count2 3注 lottermoney 单价 cplay2 号码 
						//<span class="item">用户<span class="nickname">黎志**3</span>在"冠军"玩法 下注 <span class="important">￥750</span></span>
						var zhushu
						var haoma
						var lotterMoney = item.lottermoney
						var userName = item.huiyuanzh.slice(0, item.huiyuanzh.length - 1) + "*"
						for (var j = 1; j < 41; j++) {
							if (item["count" + j] != 0) {
								zhushu = item["count" + j]
								haoma = item["cplay" + j]
								var xiazhuMoney = (zhushu * lotterMoney).toFixed(2)
								var html = "<span class='item'>用户<span class='nickname'>" + userName + "</span>在" + haoma + "玩法 下注 <span class='important'>￥" + xiazhuMoney + "</span></span>"
								$("#test1").find("nobr").append(html)								
							}
						}
					}	
			 		window.setInterval(function() {
						var x = Number($("#test1").css("margin-left").replace("px", ""));
						if (x < -3900) {
							$("#test1").css("margin-left", "300px");
						} else {
							$("#test1").css("margin-left", (x - 1) + "px");
						}
					}, 20) 						
				},
				error: function(status) {
					console.log("status", status)
				}
			}
			ajax(newRequest)	
	}
	setSlideData()

		function clear1() {
			$(".act").removeClass("act");
			$(".wfdiv input").val("");
			$("#zhushu").text("0")
		}
		function submit(){
			$(".zdsd").addClass("hidden");
		}
		
		var confirmXiaZhu = function(rebate, testState, slv) {
			var odd = 1
			if ($("#checkboxhm").is(':checked')) {
				odd = 2
			} 
			else if ($("#checkboxgd").is(':checked')) {
				odd = 3
			}
		
			var ajaxData = {
				url: '/order/awards.do',
				type: "post",
				data: {
					lotterid: $("#id").text(),
					cname: $("#cname").text(),
					cname1: $("#cname1").text(),
					period: Number($(".period").text())+1,
					lottermoney:$("#dzje").val(),
					odds:odd
				},
				success: function(data) {
					var json = eval('(' + data + ')');
					var mess = json.message;
					if(json.state==1){
						if(mess=='0'){
							showNormalNoticeModal("#div-i-noticeGenDan", "提示：", json.data)
						}else{
							$("#balance").text("￥"+json.message)
							//alertme("下注成功")
							var parentUl = document.querySelector(".ul-c-betSuccessItem")
							var wanfaHTML = ""
							for (var i = 1; i <= 40; i++) {
								var item = json.data["cplay" + i]
								if (item != null) {
									var value = json.data["cplay" + i] + ":" + json.data["str" + i]
									value = "<li>" + value + "</li>"
									wanfaHTML += value
								}
							}
							var shouyizhi = (Number(json.data.lottermoney) * Number(MONEY_FROM_SERVER)).toFixed(2)
							parentUl.innerHTML = "<li>★投注注数: <span style='color:red;font-weight:bold;'>" + COUNT_FROM_SERVER + " 注</span></li>"+
							"<li>★预估收益值:<span style='color:red;font-weight:bold;'> " + shouyizhi + " 元</span></li>"+
							"<li class='wanfa-li-special'>★玩法:</li>"+
							"<li>" + wanfaHTML + "</li>"
							var orderId = json.data.id;
							if($("#checkboxhm").is(":checked")){
								var zcount=$(".fs").val();
								var price=$(".meifen").text();
								var profit=$(".tc").val();
								var rcount=$(".rg").val();
								var bcount=$(".bd").val();
								ajax({
									url:'/order/submit.do',
									type:'post',
									data:{
										id:orderId,
										zcount:zcount,
										price:price,
										rcount:rcount,
										bcount:bcount,
										state:0,
										hcount:0,
									},
									success:function(data){
										var json = eval('(' + data + ')');
										if(json.message == "1"){
											$(".zdsd").addClass("hidden");
											clear1();
											$("#checkboxhm").removeAttr("checked");
											var html = ""
											var zongfenshuHTML = "<li>★总份数：<span style='color:red;font-weight:bold;'>" + zcount + " 份</span></li>"
											var rengoufenshuHTML = "<li>★认购份数：<span style='color:red;font-weight:bold;'>" + rcount + " 份</span></li>"
											var baodifenshuHTML = "<li>★保底份数：<span style='color:red;font-weight:bold;'>" + bcount + " 份</span></li>"
											html = zongfenshuHTML + rengoufenshuHTML + baodifenshuHTML
											$(".wanfa-li-special").before(html)
											$("#betSuccessModal .modal-title").text("发起合买成功!")
											$("#betSuccessModal").modal("show")
											setXianZhuZongE()
										}
									}
								});
							} 
							else if ($("#checkboxgd").is(":checked")) {
								//rebate, testState
								// 订单id ,huiyuanzh, beishu, payMoney,testState,state
								var stateValue = testState == "1" ? "1" : "0"
								var allMoney = Number($("#zhushu").text()) * Number($("#dzje").val())
								var ajaxDataItem = {
										id:orderId,
										testState: stateValue,
										state: "0",
										odd: odd,
										rebate: rebate,
										payMoney: allMoney
									}
								if (stateValue == "1") {
									ajaxDataItem.shenglv = slv
								}
								ajax({
									url:'/order/payGendan.do',
									type:'post',
									data: ajaxDataItem,
									success:function(data){
										var newData = JSON.parse(data)
										$("#betSuccessModal .modal-title").text("跟单成功!")
										$("#betSuccessModal").modal("show")
										$("#checkboxgd").prop("checked", false)
									}
								});								
							}
							else {
								$("#betSuccessModal .modal-title").text("下注成功!")
								$("#betSuccessModal").modal("show")
								setXianZhuZongE()
							}
							clear1()
						}
					}
				}
			}		
			//$("#dzje").val($(".temp").length)
			for (var i = 0; i < $(".temp").length; i++) {
				/* var elementName = "#temp" + index */
				var item = ($(".temp").eq(i).val() != undefined) ? $(".temp").eq(i).val() : ''
				var paramName = "str" + String(i + 1)
				ajaxData.data[paramName] = item
			}
			ajax(ajaxData);			
		}
		
		/* $("#dzje").val($(".temp").length) */
		function comit() {
			if ($("#checkboxhm").is(':checked') && $("#checkboxgd").is(':checked')) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "跟单与合买只能同时选中一个")
				$("#checkboxhm").prop('checked', false)
				$("#checkboxgd").prop('checked', false)
				return
			}
			if (!checkValueIsNumber($("#dzje").val())) {
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "无效的单注金额")
				return
			}
			// getTestState
			
			//if ($("#checkboxgd").is(':checked') && )
			if($("#zhushu").text()!="0"){
				if ($("#checkboxgd").is(':checked'))  {
					ajax({
						url:'/order/getTestState.do',
						type:'post',
						data:{},
						success:function(data){
							//confirmXiaZhu()
							var newData = JSON.parse(data)
							var dataArray = newData.message.split(",")
							confirmXiaZhu(dataArray[0], newData.data, dataArray[1])
						}
					})
				} else {
					confirmXiaZhu()
				}				
			}
			else{
				showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请选择号码")
			}
		}
		
		function comit1() {
			var ajaxData = {
				url: '/order/awards1.do',
				type: "post",
				data: {
					lotterid: $("#id").text(),
					cname: $("#cname").text(),
					cname1: $("#cname1").text(),
					period: Number($(".period").text())+1,
				},
				success: function(data) {
					var json=eval('('+data+')');
					$("#zhushu").text(json.data)
					if(json.data<1){
						$("#queding").attr("disabled","disabled");
					}
					MONEY_FROM_SERVER = json.message
					COUNT_FROM_SERVER = json.data
				}
			}		
			//$("#dzje").val($(".temp").length)
			for (var i = 0; i < $(".temp").length; i++) {
				/* var elementName = "#temp" + index */
				var item = ($(".temp").eq(i).val() != undefined) ? $(".temp").eq(i).val() : ''
				var paramName = "str" + String(i + 1)
				ajaxData.data[paramName] = item
			}
			ajax(ajaxData);
		}
		function help(url, str) {
			document.write("<form action=/help.do method=post name=form1 style='display:none'>");
			document.write("<input type=hidden name=url value='" + url + "'/>");
			document.write("<input type=hidden name=str value='" + str + "'/>");
			document.write("</form>");
			document.form1.submit();
		}
		$(function(){
/* 			var allHeight = document.documentElement.clientHeight
			var headerHeight = 112
			var bottomDivHeight = document.querySelector("#foot").clientHeight
			var restHeight = allHeight - headerHeight - bottomDivHeight
			var mainDiv = document.querySelector(".class-div-mainDiv")
			mainDiv.style.height = String(restHeight) + "px" */
			
			$(".user").click(function(){
				if($(".nav").attr("class").indexOf("hidden")!=-1){
					$(".nav").removeClass("hidden");
				}else{
					$(".nav").addClass("hidden");
				}
			});
			
			$(".wfbtn").click(function(){
				xz($("#id").text(),$("#cname").text(),$(this).attr("class").replace("wfbtn ",""))
			});
			$(".wf a").click(function(){
				$(".acti").removeClass("acti")
				$(this).addClass("acti")
			});
			$("#range,#danzhu").bind('input propertychange', function() {
				jisuan();
		    });
			
			
			$(".hemei .fs").blur(function() {
				var reg = /^[1-9]\d*$/;
				var heji1=$("#zhushu").text();
				var jieguo=heji1/Number($(".fs").val());
				if(!reg.test(Number($(".fs").val().trim()))){
					$(".fs").val("1");
				}else if(heji1/Number($(".fs").val())=="Infinity"){
					$(".fs").val("1");
				}else if(jieguo<1){
					$(".fs").val("1");
				}else{
					if(jieguo.toString().indexOf(".")!=-1&&jieguo.toString().split(".")[1].length>3){
						jieguo=jieguo.toString().split(".")[0]+"."+(Number(jieguo.toString().split(".")[1].substr(0,3))+1);
					}
					$(".meifen").text(jieguo*Number($("#dzje").val()));
					$(".rengou").text(accMul(Number($(".rg").val()),Number($(".meifen").text())));
					$(".baodi").text(accMul(Number($(".bd").val()),Number($(".meifen").text())));
				}
			});
			$(".hemei .rg").blur(function() {
				var reg = /^[1-9]\d*$/;
				if(!reg.test(Number($(".rg").val().trim()))){
					$(".rg").val("1");
				}else if((Number($(".rg").val()))>(Number($("#zhushu").text()))){
					$(".rg").val("1");
				}
				$(".rengou").text(accMul(Number($(".rg").val()),Number($(".meifen").text())));
			});
			$(".hemei .bd").blur(function() {
				var reg = /^[0-9]\d*$/;
				if(!reg.test(Number($(".bd").val().trim()))){
					$(".bd").val("0")
				}else if((Number($(".bd").val().trim())+Number($(".rg").val()))>Number($(".fs").val())){
					$(".bd").val("0")
				}
				$(".baodi").text(accMul(Number($(".bd").val()),Number($(".meifen").text())));
			});
			
			$("#checkboxhm").click(function(){
				if($(".zdsd").attr("class").indexOf("hidden")!=-1){
					if(Number($("#zhushu").text())!=0){
						$(".zdsd").removeClass("hidden");
						$("#checkboxgd").prop("checked", false)
					}else{
						showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "请先选择号码，再选择合买")
						$("#checkboxhm").removeAttr("checked");
					}
				}else{
					$(".zdsd").addClass("hidden");
				}
			});
			qiu();
		});
		/* $(".btn2,.btn3").click(function(){ */
		var IS_USER_MOVE = false
		if (isMobile()) {
			$(".xiazhu .col-xs-6,.xiazhu .myfl").on("touchstart",function(){
				IS_USER_MOVE = false
			})
			$(".xiazhu .col-xs-6,.xiazhu .myfl").on("touchmove",function(){
				IS_USER_MOVE = true
			})			
		}
		$(".xiazhu .col-xs-6,.xiazhu .myfl").on(getEndClickEvent(),function(){
			if (IS_USER_MOVE && isMobile()) {
				return
			}
			$(".queren").text("确定");
			if($(this).attr("class").indexOf("act")!=-1){
				$(this).removeClass("act");
			}else{
				if($("#cplay").text().indexOf("dt")!=-1){
					var q=$(this).attr("class").replace("btn2 ","");
					$("."+q).removeClass("act");
					$("#temp1").val($("#temp1").val().replace(q+",",""))
					$("#temp2").val($("#temp2").val().replace(q+",",""))
				}
				$(this).addClass("act");
			}
			if($(this).find("button").length==1){
				$a=$(this).parent().find("div");
				$input=$(this).siblings("input");
				$input.val("");
				for(var i=0;i<$a.length;i++){
					/* if($("#cplay").text().indexOf('bz')!=-1||$("#cplay").text().indexOf('3thtx')!=-1||$("#cplay").text().indexOf('3lhtx')!=-1){
						if($(".act").text()==''){
							$("#temp1").val("");
						}else{
							$("#temp1").val($(".act").text()+",");
						}
					}else */ 
					if($a.eq(i).attr("class").indexOf("act")!=-1){
						$input.val($input.val()+$a.eq(i).find("button").text()+",");
					}
					if($input.val().indexOf("单")!=-1&&$(this).find("button").eq(0).text().indexOf("双")!=-1){
						$input.val($input.val().replace("单,",""))
						if($a.eq(i).find("button").eq(0).text().indexOf("单")!=-1){
							$a.eq(i).removeClass("act")
						}
					}else if($input.val().indexOf("双")!=-1&&$(this).find("button").eq(0).text().indexOf("单")!=-1){
						$input.val($input.val().replace("双,",""))
						if($a.eq(i).find("button").eq(0).text().indexOf("双")!=-1){
							$a.eq(i).removeClass("act")
						}
					}
					if($input.val().indexOf("大")!=-1&&$(this).find("button").eq(0).text().indexOf("小")!=-1){
						$input.val($input.val().replace("大,",""))
						if($a.eq(i).find("button").eq(0).text().indexOf("大")!=-1){
							$a.eq(i).removeClass("act")
						}
					}else if($input.val().indexOf("小")!=-1&&$(this).find("button").eq(0).text().indexOf("大")!=-1){
						$input.val($input.val().replace("小,",""))
						if($a.eq(i).find("button").eq(0).text().indexOf("小")!=-1){
							$a.eq(i).removeClass("act")
						}
					}
					if($input.val().indexOf("龙")!=-1&&$(this).find("button").eq(0).text().indexOf("虎")!=-1){
						$input.val($input.val().replace("龙,",""))
						if($a.eq(i).find("button").eq(0).text().indexOf("龙")!=-1){
							$a.eq(i).removeClass("act")
						}
					}else if($input.val().indexOf("虎")!=-1&&$(this).find("button").eq(0).text().indexOf("龙")!=-1){
						$input.val($input.val().replace("虎,",""))
						if($a.eq(i).find("button").eq(0).text().indexOf("虎")!=-1){
							$a.eq(i).removeClass("act")
						}
					}
					
					var text=$input.val().replace("大,","").replace("小,","").replace("单,","").replace("双,","").replace("龙,","").replace("虎,","").replace("和,","")
					if(text.split(",").length>6){
						$aaa=$input.val().split(",");
						for(var j=0;j<$aaa.length;j++){
							if(!isNaN(Number($aaa[j]))){
								var text1=$input.val().replace("大,","").replace("小,","").replace("单,","").replace("双,","").replace("龙,","").replace("虎,","").replace("和,","")
								if(text1.split(",").length-1>6){
									if($(this).find("button").eq(0).text()>text1.split(",")[0]){
										$input.val($input.val().replace($aaa[j]+",",""))
									}else{
										console.log(text[text1.split(",").length])
										$input.val($input.val().replace($aaa[text1.split(",").length]+",",""))
									}
								}
							}
						}
					}
				}
			}else{
				$input=$(this).parent().siblings("input");
				$input.val("");
				for(var i=0;i<$a.length;i++){
					if($a.eq(i).attr("class").indexOf("act")!=-1){
						$input.val($input.val()+$a.eq(i).text()+",");
					}
				}
			}
			
			$a=$(this).parent().find("div");
			$b=$(this).siblings("input").val().split(",");
			/* $a=$(this).parent().find("div"); */
			$($a.removeClass("act"))
			for(var j=0;j<$b.length-1;j++){
				for(var i=0;i<$a.length;i++){
					if($b[j]==$a.eq(i).find("button").text()){
						$a.eq(i).addClass("act")
					}
				}
			}
			
			comit1();
		});
		var ChangeNewQiHaoflag = true
		var dd=window.setInterval(function(){
			var time1 = new Date().format("hh:mm:ss").split(":");
			time1=Number(time1[0]*60*60)+Number(time1[1]*60)+Number(time1[2]);
			var time=$(".lasttime").text().split(" ")[1].split(":");//上期开奖 
			time=Number(time[0]*60*60)+Number(time[1]*60)+Number(time[2]);
			time=time+Number($(".timespace").text().split(",")[0])-time1;
			time--;
			var hour=Math.floor(time/3600);
			var minute=Math.floor((time-hour*3600)/60);
			var second=time-hour*3600-minute*60;
/* 			console.log("time", time) */
			if(-15 < time && time < 30){
				$("#fenpan").removeClass("hidden");
			}
			if (time < -15 && ChangeNewQiHaoflag) {
				// 之前的 time $(".lasttime")
				// $(".timespace").text().split(",")[0]
				var newTime = $(".lasttime").text().split(" ")[1].split(":");//上期开奖 
				newTime = Number(newTime[0]*60*60)+Number(newTime[1]*60)+Number(newTime[2]);
				var sTime = Number($(".timespace").text().split(",")[0])
				var allTime = newTime + sTime  //要把这个秒数转成 时分秒
				var hour2 =Math.floor(allTime/3600);
				var minute2 =Math.floor((allTime-hour2*3600)/60);
				var second2 =allTime-hour2*3600-minute2*60;	
/*  				console.log("hour2", hour2)
				console.log("minute2", minute2)
				console.log("second2", second2) */
				var newLastTime = "jyj "+ bu0(hour2)+":"+bu0(minute2)+":"+bu0(second2)
				var currentQiHao = $(".xiaqi").text()
				$(".lasttime").text(newLastTime)
				$("#fenpan").addClass("hidden")
				$(".period").text(currentQiHao)
				$(".xiaqi").text(Number(currentQiHao) + 1)
				$(".period").parent().find(".lotternumber").html("<div class='text-center yuan qiu'>正</div><div class='text-center yuan qiu'>在</div><div class='text-center yuan qiu'>开</div><div class='text-center yuan qiu'>奖</div>")
				ChangeNewQiHaoflag = false
				var setLastKaiJiangHaoMa = setInterval(function() {
					ajax({
						url:'/lotter/getnewdata.do',
						type:'post',
						data:{key:$("#cname").text()},
						success:function(data){
							var json=eval('('+data+')');
							if($(".period").text()==json.data.period){
								$(".lotternumber").text(json.data.lotternumber);
								/* $(".xiaqi").text(Number(json.data.period)+1); */
								/* $(".period").text(json.data.period); */
								/* $(".lasttime").text(json.data.lottertime); */
								qiu();
								clearInterval(setLastKaiJiangHaoMa)
								ChangeNewQiHaoflag = true
								/* $("#fenpan").addClass("hidden"); */
							}/* else{console.log($(".xiaqi").text()+" @"+json.data.period)} */
						},
					})					
				}, 1000)
			}
			
			if(time<0){
				$("#djs").html("<div class='text-center yuan qiu'>正</div><div class='text-center yuan qiu'>在</div><div class='text-center yuan qiu'>开</div><div class='text-center yuan qiu'>奖</div>");
				getnewdata();
			}else{
				$("#djs").text("距封盘 "+bu0(hour)+":"+bu0(minute)+":"+bu0(second));
			}
			
/* 				$(".lotternumber").text(json.data.lotternumber);
				$(".xiaqi").text(Number(json.data.period)+1);
				console.log(Number(json.data.period)+1);
				$(".period").text(json.data.period);
				$(".lasttime").text(json.data.lottertime); 
				qiu();
				$("#fenpan").addClass("hidden"); */
			// 拿了 10 秒还是拿不到,
			// 
		},1000);
		
		$("body").append("<div id='fenpan' class='hidden' style='position: fixed;bottom:0px;width:100%;background:rgba(200,200,200,0.8);height:55px;line-height:55px;font-size:30px;text-align:center;color:white;'>已封盘</div>");
		
		
		function qiu(){
			var lotternumber=$(".lotternumber").text().split(",");
			var lotter="";
			for(var i=0;i<lotternumber.length-1;i++){
				var x = Number(lotternumber[i]);
				lotter+="<div style='margin:1px;color:white;width:0.46rem;height:0.46rem;line-height:0.46rem;font-size:0.33rem;display:inline-block;'";
				if($("#cname").text().indexOf("pk10")!=-1){
					lotter+="class='text-center yuan qiu"+x+"'>"+lotternumber[i]+"</div>";
				}else{
					lotter+="class='text-center yuan qiu8'>"+lotternumber[i]+"</div>";
				}
			}
			var lotternumber1=$(".lotternumber1").text().split(",");
			$(".lotternumber").html(lotter);
		}
		
		function getnewdata(){
			ajax({
				url:'/lotter/getnewdata.do',
				type:'post',
				data:{key:$("#cname").text()},
				success:function(data){
					var json=eval('('+data+')');
					if($(".xiaqi").text()==json.data.period){
						$(".lotternumber").text(json.data.lotternumber);
						$(".xiaqi").text(Number(json.data.period)+1);
						console.log(Number(json.data.period)+1);
						$(".period").text(json.data.period);
						$(".lasttime").text(json.data.lottertime);
						qiu();
						$("#fenpan").addClass("hidden");
					}/* else{console.log($(".xiaqi").text()+" @"+json.data.period)} */
				},
			});
		}
		

			var allHeight = document.documentElement.clientHeight
			var qiuGroupHeight = document.querySelector(".class-div-qiuGroups").clientHeight
			var footHeight = document.querySelector("#div-i-footer-hemai").clientHeight
			var restHeight = allHeight - qiuGroupHeight - footHeight - 50
			console.log("all", allHeight)
			console.log("qui", qiuGroupHeight)
			console.log("rest", restHeight)
			document.querySelector(".class-div-contentDiv").style.height = restHeight + "px"
			window.onload=function () {
			    document.addEventListener('touchstart',function (event) {
			        if(event.touches.length>1){
			            event.preventDefault();
			        }
			    })
			    var lastTouchEnd=0;
			    document.addEventListener('touchend',function (event) {
			        var now=(new Date()).getTime();
			        if(now-lastTouchEnd<=500){
			            event.preventDefault();
			        }
			        lastTouchEnd=now;
			    },false)
			}	
			var insertNewData = function(arr) {
				var div = document.querySelector(".modal-body")
				var currentCName = $("#cname").text()
				div.innerHTML = ""
				for (var i = 0; i < arr.length; i++) {
					var item = arr[i]
					var spanArray = item.lotternumber.slice(0, item.lotternumber.length - 1)
					spanArray = spanArray.split(",")
					var spanHTML = ""
					for (var j = 0; j < spanArray.length; j++) {
						var spanItem = spanArray[j]
						var specialClass = ""
						if (SPECIAL_CAIZHONG.includes(currentCName)) {
							specialClass = COLOR_OBJECT[j + 1]
						}
						var html = "<span class='span-item-circle " + specialClass + "'>" + spanItem + "</span>"
						spanHTML += html
					}
					var html = "<div class='green'>"+
					"期号：<span>" + item.period + "</span><br>"+
					"奖号：" + spanHTML + "<br>"+
					"日期：<span>" + item.lottertime + "</span>"+
				"</div>"
				console.log("html", html)
					div.insertAdjacentHTML("beforeend", html)
				}
			}
			
			document.querySelector("#a-i-lotterRecord").addEventListener(getEndClickEvent(), function(event) {
			 	var urlPath = "/caizhongjl.do"
				var newRequest = {
					url: urlPath,
					type: "post",
					data: {
						cname: $("#cname").text()
					},
					success: function(data) {
						var newData = JSON.parse(data)
						var bodyModal = document.querySelector(".modal-body")
						insertNewData(newData.data)
						$("#myModal").modal("show")
 					},
					error: function(status) {
						console.log("status", status)
					}
				}
				ajax(newRequest)		
			})
var timerId = null 			
		$("#dzje").focus(function(event) {
		var explorer = navigator.userAgent
		if(explorer.indexOf("Safari") >= 0){
/* 				setInterval(function () {
	            scrollToEnd()
	        }, 500) */
		} else {
			var cnt = 0
			timerId = setInterval( function() {
			    if (cnt < 3) {
			      cnt++
			    } else {
			      clearInterval(timerId)
			      timerId = null
			      return
			    }
			   document.body.scrollTop = document.body.scrollHeight
			   //window.scrollTo(0, document.body.scrollHeight)
		  }, 300)				
		}
	})		
	$("#dzje").on("blur", function(event) {
	    if (timerId) {
		    clearInterval(timerId);
		    timerId = null;
		}
	    if (interval) {
			clearInterval(interval);
	    }
	})	
/* 			
function getQueryString(name) { 
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
        var r = window.location.search.substr(1).match(reg); 
        if (r != null) return unescape(r[2]); 
        return null; 
}			
	var getPeiLvData = function() {
		var str = getQueryString("zl")
		console.log("str", str)
		 	var urlPath = "/cp/czgl/getCzxinxi.do"
			var newRequest = {
				url: urlPath,
				type: "post",
				data: {
					cname: str						
				},
				success: function(data) {
					var newData = JSON.parse(data)
					console.log("newData", newData)
					if (str == "xg6hc") {
						
					} else {
						
					}
				},
				error: function(status) {
				}
			}
			ajax(newRequest) 			
	}
	getPeiLvData() */
	$("#a-i-zoushitu").on(getEndClickEvent(), function() {
		var lotterName = "${lotter.cname }"
		console.log("nn", lotterName)
		if (lotterName == "gdkl10f" || lotterName == "cqkl10f") {
			alertme("快乐十分暂无走势图")
		} 
		else if (lotterName == "xg6hc") {
			alertme("香港六合彩暂无走势图")
		}
		else {
			location.href = "/cp/zoushitu.do?caizhong=" + lotterName
		}
	})
	//span-i-xiazhuzonge
	var setXianZhuZongE = function() {
	 	var urlPath = "/order/orderSum.do"
			var newRequest = {
				url: urlPath,
				type: "post",
				data: {
					period: $(".xiaqi").text(),
					cname: $("#cname").text(),
				},
				success: function(data) {
					var newData = JSON.parse(data)
					console.log("newData", newData)
					$("#span-i-xiazhuzonge").text(newData.data)
				},
				error: function(status) {
				}
			}
			ajax(newRequest)		
	}
	setXianZhuZongE()
	$("#checkboxgd").on("change", function(event) {
		if ($(".act").length === 0 && event.currentTarget.checked) {
			showNormalNoticeModal("#div-i-noticeGenDan", "提示：", "必须要选择号码后才可以选择跟单")
			$("#checkboxgd").prop("checked", false)
			return
		}
		if (event.target.checked) {
			$("#checkboxhm").prop("checked", false)
		}
	})
	</script>
</html>
